package com.ebupt.migu.music.tapi;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import com.ebupt.migu.restapi.UploadBySFTP;

import lombok.extern.slf4j.Slf4j;

/**
 * @author liuyangyang@e-byte.com
 * @description: TODO
 * @date 2023/10/17 10:42
 */
@Slf4j
@RestController
@RequestMapping("/test/api")
public class TestApiController {

    @Autowired
    private RedisTemplate redisTemplate;

    @PostMapping("/sftp/download")
    public boolean add(@RequestBody String filename) {
        return UploadBySFTP.getSftpFile("10.25.245.39", 8822, "ftpd", "Music#2020", "/fine-operation-label/",
            "/apps/dxby_liuyangyang/files/fine-operation-label/tsg-files-sync/", "20231017.txt");
    }

    @GetMapping("/redis")
    public boolean redis() {
        String uid_str =
            "eb55ba8a-6d35-490b-8fda-fcd983159c4d,738130d6-4574-4beb-8a3f-b0bae15bcf17,35654f7f-d28e-4811-9d9c-5c41be270267,2f0d63d3-4d97-41e4-bb01-b3e0ddf57fe2,2e76988b-3186-416a-946f-8330a8050495,5d523beb-7571-4e7a-a463-97df0aaa9525,91735555946,91902099312,17562600";
        List<String> uids = Arrays.asList(uid_str.split(","));
         for (String uid : uids) {
         redisTemplate.opsForSet().add("BQ20230809152154-uid", uid);
         redisTemplate.opsForSet().add("PUSH_THRESHOLD_GRAYSCALE_USERS", uid);
         log.info(uid);
         }
        return true;
    }
}
